package o;

import android.content.Intent;
import android.os.Bundle;
import android.os.Parcelable;
import com.huawei.appgallery.foundation.card.base.bean.KeywordInfo;
import com.huawei.appmarket.framework.widget.FixedSearchView;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;

public class djn {
    private boolean ʻ = false;
    private long ʼ = 0;
    private KeywordInfo ʽ;
    private int ˊ = -1;
    private Timer ˋ = new Timer();
    private int ˎ = -1;
    private TimerTask ˏ;
    private List<KeywordInfo> ॱ = null;

    public djn(int i) {
        this.ˊ = i;
    }

    public void ˏ(List<KeywordInfo> list) {
        this.ॱ = list;
        if (this.ˎ == -1 && this.ˏ != null) {
            ᐝ();
            ॱ(0);
        }
        this.ˎ = -1;
    }

    private void ˋ() {
        Parcelable ˏ = ˏ();
        Intent intent = new Intent();
        Bundle bundle = new Bundle();
        bundle.putParcelable("keyWord", ˏ);
        bundle.putInt("TaskId", this.ˊ);
        intent.putExtras(bundle);
        intent.setAction(FixedSearchView.ˎ());
        ll.ˏ(ContentManager.getInstant().getContext()).ˋ(intent);
    }

    public void ॱ(long j) {
        if (this.ˋ == null) {
            this.ˋ = new Timer();
        }
        if (this.ˏ == null) {
            this.ˏ = new TimerTask(this) {
                final /* synthetic */ djn ˋ;

                {
                    this.ˋ = r1;
                }

                public void run() {
                    if (!CollectCheck.isEmpty(this.ˋ.ॱ)) {
                        this.ˋ.ˋ();
                        if (this.ˋ.ʻ) {
                            this.ˋ.ᐝ();
                        }
                    }
                }
            };
            this.ˋ.schedule(this.ˏ, j, 5000);
        }
    }

    public void ˊ() {
        this.ʻ = true;
        ᐝ();
    }

    private void ᐝ() {
        if (this.ˋ != null) {
            this.ˋ.cancel();
            this.ˋ = null;
        }
        if (this.ˏ != null) {
            this.ˏ.cancel();
            this.ˏ = null;
        }
    }

    public void ˎ() {
        if (this.ʻ) {
            this.ʻ = false;
            ॱ(5000);
        }
    }

    public KeywordInfo ˏ() {
        KeywordInfo keywordInfo = null;
        if (!CollectCheck.isEmpty(this.ॱ)) {
            this.ˎ = (this.ˎ + 1) % this.ॱ.size();
            if (this.ˎ < this.ॱ.size()) {
                keywordInfo = (KeywordInfo) this.ॱ.get(this.ˎ);
            }
            ˎ(keywordInfo);
        }
        return keywordInfo;
    }

    public KeywordInfo ॱ() {
        return this.ʽ;
    }

    private void ˎ(KeywordInfo keywordInfo) {
        this.ʽ = keywordInfo;
    }

    private long ʻ() {
        return this.ʼ;
    }

    private void ˊ(long j) {
        this.ʼ = j;
    }

    public boolean ˎ(boolean z) {
        long currentTimeMillis = System.currentTimeMillis();
        if (Math.abs(currentTimeMillis - ʻ()) <= 1000 || z) {
            return false;
        }
        ˊ(currentTimeMillis);
        return true;
    }
}
